<div class="hbox hbox-auto-xs hbox-auto-sm" ng-init="
    app.settings.asideFolded = false;
    app.settings.asideDock = false;
  ">
    <!-- main -->
    <div class="col">
        <!-- main header -->
        <div class="bg-light lter b-b wrapper-md">
            <div class="row">
                <div class="col-sm-6 col-xs-12">
                    <h1 class="m-n font-thin h3 text-black">日志服务</h1>
                    <small class="text-muted">Nginx访问日志查询</small>
                </div>
            </div>
        </div>
        <!-- / main header -->
        <div class="wrapper-md">
            <!-- toaster directive -->
            <toaster-container
                    toaster-options="{'position-class': 'toast-top-right', 'close-button':true}"></toaster-container>
            <!-- / toaster directive -->

            <uib-tabset>
                <uib-tab index="0" heading="Nginx访问日志查询">
                    <div class="panel panel-default" ng-controller="nginxLogCtrl">
                        <div class="panel-body">


                            <div class="form-group">
                                <div class="col-md-6">
                                    <!--<span style="color: #ec2121;">*</span>-->
                                    <label class="col-lg-2 control-label">域名</label>
                                    <div class="col-lg-8">
                                        <ui-select ng-model="nowLogServiceCfg.selected" theme="bootstrap">
                                            <ui-select-match placeholder="搜索域名配置......">
                                                {{$select.selected.serverName}}
                                            </ui-select-match>
                                            <ui-select-choices refresh="queryLogServiceCfg($select.search)"
                                                               refresh-dalay="0"
                                                               repeat="item in logServiceCfgList | filter: $select.search">
                                                <div ng-bind-html="item.serverName | highlight: $select.search"></div>
                                            </ui-select-choices>
                                        </ui-select>
                                    </div>
                                    <div class="form-group" ng-if="nowLogServiceCfg.selected != null">
                                        <button type="button" class="btn btn-info" ng-click="doQuery()">
                                            <i class="fa fa-spin fa-spinner" ng-show="btnDoQuery"></i>
                                            <i class="glyphicon glyphicon-search" ng-show="!btnDoQuery"></i>搜索
                                        </button>
                                    </div>
                                </div>

                            </div>

                            <div style="font-size:2em;">&nbsp;</div>

                            <form class="form-horizontal" style="box-shadow: 0 0 5px #ddd;padding: 10px;"
                                  ng-if="nowLogServiceCfg.selected != null">
                                <div class="form-group">
                                    <div class="col-md-6">
                                        <label class="col-lg-2 control-label">开始时间</label>
                                        <div class="col-lg-5">
                                            <div class="input-group">
                                                <input type="text" class="form-control" uib-datepicker-popup
                                                       ng-model="queryItem.beginDate"
                                                       is-open="popupBeginDate.opened" datepicker-options="dateOptions"
                                                       ng-required="true" close-text="Close"/>
                                                <span class="input-group-btn">
                                                <button type="button" class="btn btn-default"
                                                        ng-click="openBeginDate()">
                                                    <i class="glyphicon glyphicon-calendar"></i>
                                                </button>
                                            </span>
                                            </div>
                                        </div>
                                        <div class="col-md-5">
                                            <div uib-timepicker arrowkeys="false" ng-model="queryItem.beginTime"
                                                 ng-change="changed()"
                                                 hour-step="hstep" minute-step="mstep" show-meridian="false"
                                                 show-spinners="false"></div>
                                        </div>
                                    </div>

                                </div>

                                <div class="form-group">

                                    <div class="col-md-6">
                                        <label class="col-lg-2 control-label">结束时间</label>
                                        <div class="col-lg-5">
                                            <div class="input-group">
                                                <input type="text" class="form-control" uib-datepicker-popup
                                                       ng-model="queryItem.endDate"
                                                       is-open="popupEndDate.opened" datepicker-options="dateOptions"
                                                       ng-required="true" close-text="Close"/>
                                                <span class="input-group-btn">
                                                <button type="button" class="btn btn-default"
                                                        ng-click="openEndDate()">
                                                    <i class="glyphicon glyphicon-calendar"></i>
                                                </button>
                                            </span>
                                            </div>
                                        </div>
                                        <div class="col-md-5">
                                            <div uib-timepicker arrowkeys="false" ng-model="queryItem.endTime"
                                                 ng-change="changed()"
                                                 hour-step="hstep" minute-step="mstep" show-meridian="false"
                                                 show-spinners="false"></div>
                                        </div>
                                    </div>
                                </div>

                                <div class="form-group">
                                    <div class="col-md-4">
                                        <label class="col-lg-3 control-label">URI</label>
                                        <div class="col-lg-9">
                                            <input type="text" class="form-control" placeholder="接口"
                                                   ng-model="queryItem.uri">
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <label class="col-lg-3 control-label">XFF</label>
                                        <div class="col-lg-9">
                                            <input type="text" class="form-control"
                                                   placeholder="(X-FORWARDED_FOR)HTTP请求端真实的IP"
                                                   ng-model="queryItem.http_x_forwarded_for">
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <label class="col-lg-3 control-label">STATUS</label>
                                        <div class="col-lg-9">
                                            <input type="text" class="form-control" placeholder="请求状态"
                                                   ng-model="queryItem.status">
                                        </div>
                                    </div>
                                </div>
                                <div class="form-group">
                                    <div class="col-md-4">
                                        <label class="col-lg-3 control-label">后端服务器</label>
                                        <div class="col-lg-9">
                                            <input type="text" class="form-control" placeholder="upstream_addr"
                                                   ng-model="queryItem.upstream_addr">
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <label class="col-lg-3 control-label">后端返回时间</label>
                                        <div class="col-lg-9">
                                            <input type="text" class="form-control" placeholder="upstream_response_time"
                                                   ng-model="queryItem.upstream_response_time">
                                        </div>
                                    </div>

                                    <div class="col-md-4">
                                        <label class="col-lg-3 control-label">总请求时</label>
                                        <div class="col-lg-9">
                                            <input type="text" class="form-control" placeholder="request_time"
                                                   ng-model="queryItem.request_time">
                                        </div>
                                    </div>
                                </div>
                            </form>


                            <!--日志分布视图-->
                            <uib-accordion ng-if="pageData != null && pageData != ''">
                                <div class="list-group col-md-12">
                                    <div class="panel panel-default">
                                        <div uib-accordion-group class="panel-info" is-open="logHistogramsStatusOpen">
                                            <uib-accordion-heading>日志分布视图
                                                <i class="pull-right glyphicon"
                                                   ng-class="{'glyphicon-chevron-down': myJobStatusOpen, 'glyphicon-chevron-right': !myJobStatusOpen}"></i>
                                            </uib-accordion-heading>
                                            <div style="margin-top: 5px;">
                                                <table class="table table-striped">
                                                    <thead>
                                                    <tr>
                                                        <td class="col-md-4">开始时间</td>
                                                        <td class="col-md-4">结束时间</td>
                                                        <td class="col-md-2">日志条目</td>
                                                        <td>操作</td>
                                                    </tr>
                                                    </thead>
                                                    <tbody>

                                                    <tr ng-repeat="item in pageData">
                                                        <td>
                                                            <b style="color: #286090">{{item.gmtFrom}}</b>
                                                        </td>
                                                        <td>
                                                            <b style="color: #286090">{{item.gmtTo}}</b>
                                                        </td>
                                                        <td>
                                                            <b style="color: #286090">{{item.totalCount}}</b>
                                                        </td>
                                                        <td>
                                                            <button ng-click="nginxLogList(item)"
                                                                    ng-show="item.totalCount < 200"
                                                                    uib-popover-html="'查询日志详情'"
                                                                    popover-trigger="'mouseenter'"
                                                                    class="btn btn-xs"
                                                                    style="background-color: #2e6da4; color: white;">
                                                                <i class="glyphicon glyphicon-search"></i>日志详情
                                                            </button>

                                                            <div ng-show="item.totalCount >= 200"
                                                                 uib-popover-html="'超过200条不允许查看详情，请使用条件过滤！'"
                                                                 popover-trigger="'mouseenter'"
                                                                 class="label"
                                                                 style="background-color: #c9302c; color: white;">
                                                                <i class="glyphicon glyphicon-remove"></i>条目过多
                                                            </div>
                                                        </td>
                                                    </tr>
                                                    </tbody>
                                                    <tfoot>
                                                    <tr>
                                                        <td colspan="4">
                                                            <ul style="margin: 0px; float: right;" uib-pagination
                                                                total-items="totalItems" ng-model="currentPage"
                                                                items-per-page="pageLength" max-size="10"
                                                                ng-change="pageChanged(currentPage)"
                                                                previous-text="&lsaquo;" next-text="&rsaquo;"></ul>
                                                        </td>
                                                    </tr>
                                                    </tfoot>
                                                    </tbody>
                                                </table>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </uib-accordion>


                        </div>
                    </div>
                </uib-tab>
            </uib-tabset>
        </div>
    </div>
    <!-- / main -->
</div>


<script type="text/ng-template" id="nginxLogInfo">
    <div ng-include="'tpl/modal/logservice/nginx_log_info_modal.html'"></div>
</script>

